<#include "public.ftl">
/***********************************************************

 *FileName:      ${apiDataList[0].group}
 *Description:
 *Version:       1.0.0_alpha
 *Aurthor:       ZhangAY
 *CreateDate:    2018-10-26

 --------------------------------------------------------
 *updateDate:
 *Aurthor:
 *Description:

 ***********************************************************/
define(['/assets/js/core/utils.js'], function (utils) {
    'use strict';
    var api = {};
<#list apiDataList as apiData>

    /**
    *
    * ${apiData.description}<br/>
    * 参数为以下对象子集:
    * defaultParam = {
    * <#list apiData.parameter.fields.parameter as apiParam>
    *  ${funcs.StringUtils.rightPad(apiParam.field+":null,",18)}//类型:${apiParam.type},<#if apiParam.optional == true>[可选]</#if>${apiParam.description?replace("<p>","")?replace("</p>","")}<br/></#list>
    * }
    * @param param 请求参数
    * @param opts [可选]ajax参数
    * */
    api.${apiData.name} = function (param, opts) {
        // 默认参数
        var defaultParams = {
    <#list apiData.parameter.fields.parameter as apiParam>
        ${apiParam.field}: null<#if apiParam_has_next>,</#if>
    </#list>
        };
        // 过滤掉错误的参数
        param = utils.commonFuncs.mergeQueryParams(defaultParams, param);
        // 删除空值参数
        param = utils.commonFuncs.deleteEmptyProperties(param);
        // 默认ajax请求参数
        var defaultOpts = {
            type: "${apiData.type}",
            url: waterUrl + ${apiData.url}
        };
        if (opts) {
            $.extend(true, defaultOpts, opts);
        }
        defaultOpts.data = JSON.stringify(param);
        return utils.ajax(ajaxOptions);
    };
</#list>
    return api;
});